package top.system.dept.advice;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import top.system.dept.pojo.SysResp;
import top.system.dept.utils.RespUtil;

import java.sql.SQLIntegrityConstraintViolationException;

@ControllerAdvice
public class MVCAdvice {

    @ExceptionHandler(value = SQLIntegrityConstraintViolationException.class)
    @ResponseBody
    public SysResp ConstraintErrorHandler() {
        return RespUtil.uniqueInvoiceID();
    }

}
